exports.install = function (Vue, options) {
    Vue.prototype.getDate = function () {
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        if (month < 10) {
            month = "0" + month;
        }
        var day = date.getDate();
        if (day < 10) {
            day = "0" + day;
        }
        return year + "-" + month + "-" + day;
    }

    Vue.prototype.getDatetime = function () {
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var hour = date.getHours();
        var minute = date.getMinutes();
        var second = date.getSeconds();
        if (month < 10) {
            month = "0" + month;
        }
        var day = date.getDate();
        if (day < 10) {
            day = "0" + day;
        }
        if (hour < 10) {
            hour = "0" + hour;
        }
        if (minute < 10) {
            minute = "0" + minute;
        }
        if (second < 10) {
            second = "0" + second;
        }
        return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
    }

    Vue.prototype.getSimpleText = function (html) {
        // <.+?> 这个表达式指的是html标签
        var re1 = new RegExp("<.+?>|&nbsp;", "g");
        var msg = html.replace(re1, "");
        return msg;
    }

    // 定义点击上传文件之前进行判断的公共函数
    Vue.prototype.beforeUpload = function (file) {
        if (file == null) {
            return false;
        }
        // 判断上传的文件的大小，格式是否符合规范
        if (this.$Global.imageTypes.indexOf(file.type) == -1) {
            this.$message({
                message: "请检查上传图片格式的文件",
                type: "error"
            });
            return false;
        } else if (file.size / 1024 / 1024 > 2) {
            this.$message({
                message: "文件大于2M，请压缩",
                type: "error"
            });
            return false;
        }
    }

    // 文件上传完毕之后的回调函数
    Vue.prototype.afterUpload = function (response, file, fileList) {
        this.$message({ message: response.message, type: 'success' });
    }
}